package com.qqs.distributed.lock;

import com.qqs.distributed.advice.CacheAttributeWrapper;
import com.qqs.distributed.annotation.LockType;
import org.redisson.api.RedissonClient;


public class RedissonLockHandlerFactory extends AbstractLockHandlerFactory {
    private RedissonClient client;

    public RedissonLockHandlerFactory(RedissonClient client) {
        this.client = client;
    }

    @Override
    public LockHandler produce(CacheAttributeWrapper attributeWrapper) {
        if (LockType.REDISSON.equals(attributeWrapper.getAttribute().getLockType())) {
            return new RedissonLockHandler(attributeWrapper, client);
        }
        return null;
    }

}
